Skip to content

Migrate device table to TanStack Table v9 - #1660

Merged
bdraco merged 5 commits into
mainfrom
tanstack-table-v9
Aug 19, 2026
Merged

Migrate device table to TanStack Table v9#1660
bdraco merged 5 commits into
mainfrom
tanstack-table-v9

Conversation

@bdraco

@bdraco bdraco commented Aug 18, 2026

Copy link
Copy Markdown
Member

What does this implement/fix?

Takes the TanStack Table v9 major that dependabot proposed in #1649; v9 is a breaking rewrite, so the bump alone fails typecheck and tests. The row model factories move into a shared tableFeatures object (new table-features.ts), VisibilityState becomes ColumnVisibilityState, column defs use sortFn, and the table types gain the features generic. Behavior is unchanged; sorting, filtering, column visibility and pagination keep the same controlled state flow.

Supersedes #1649.

Related issue or feature (if applicable):

Types of changes

  • Bugfix (non-breaking change which fixes an issue) — bugfix
  • New feature (non-breaking change which adds functionality) — new-feature
  • Enhancement to an existing feature — enhancement
  • Breaking change (fix or feature that would cause existing functionality to not work as expected) — breaking-change
  • Refactor (no behaviour change) — refactor
  • Documentation only — docs
  • Maintenance / chore — maintenance
  • CI / workflow change — ci
  • Dependencies bump — dependencies

Checklist

  • The code change is tested and works locally.
  • pnpm run lint passes.
  • pnpm run test passes.
  • Tests have been added to verify that the new code works (where applicable).

@bdraco bdraco added the dependencies Dependency updates label Aug 18, 2026
@bdraco

bdraco commented Aug 18, 2026

Copy link
Copy Markdown
Member Author

@esphbot review

@bdraco
bdraco requested a balanced review from Copilot August 18, 2026 23:47
@bdraco
bdraco marked this pull request as ready for review August 18, 2026 23:47

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Migrates the device table to TanStack Table v9 while preserving controlled sorting, filtering, visibility, and pagination behavior.

Changes:

  • Upgrades @tanstack/lit-table to v9.1.2.
  • Introduces a shared v9 feature configuration and composed table types.
  • Updates table implementation and tests for v9 APIs and renamed types.

Reviewed changes

Copilot reviewed 10 out of 11 changed files in this pull request and generated no comments.

Show a summary per file
File Description
package.json Upgrades TanStack Lit Table.
pnpm-lock.yaml Locks v9 and its dependencies.
src/components/dashboard/table-features.ts Defines shared table features and types.
src/components/dashboard/device-table.ts Migrates table state and controller APIs.
src/components/dashboard/device-table-grid.ts Uses composed v9 table types.
src/components/dashboard/table-columns.ts Migrates column definitions and sort functions.
src/components/dashboard/render-content.ts Updates visibility event typing.
src/components/dashboard/prefs.ts Updates preference state typing.
src/pages/dashboard.ts Updates dashboard visibility state typing.
test/components/dashboard/table-columns.test.ts Migrates cell-context test types.
test/components/dashboard/prefs.test.ts Migrates visibility-state test types.
Files not reviewed (1)
  • pnpm-lock.yaml: Generated file

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@esphbot

esphbot commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Previous review — superseded by a newer review below.

@esphbot esphbot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tip

No blocking issues found — ready to merge.

Copilot AI review requested due to automatic review settings August 19, 2026 00:10
@bdraco

bdraco commented Aug 19, 2026

Copy link
Copy Markdown
Member Author

Both suggestions addressed in 270c207. Added a test pinning the auto resolved alphanumeric order on the platform column; the fixture includes host2/host10 and a case mixed value so a silent basic fallback fails the assertion rather than passing with the same order. Tightened the table-features docstring to name the unregistered datetime and basic outcomes. Moved DeviceRow into a leaf device-row.ts so table-features and table-columns no longer import each other; table-columns re-exports the type, so call sites are unchanged.

@bdraco

bdraco commented Aug 19, 2026

Copy link
Copy Markdown
Member Author

@esphbot review

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 12 out of 13 changed files in this pull request and generated no new comments.

Files not reviewed (1)
  • pnpm-lock.yaml: Generated file
Suppressed comments (1)

src/components/dashboard/table-features.ts:42

  • The new test only forces auto to choose alphanumeric because its sampled values contain digits. Removing the separately registered text comparator would therefore leave this test green, even though plain-string columns such as Area and Comment would fall back to case-sensitive basic sorting. Please add a plain-string case whose expected order distinguishes text from basic so both entries in the slim registry are covered.
  sortFns: { alphanumeric: sortFn_alphanumeric, text: sortFn_text },

@bdraco

bdraco commented Aug 19, 2026

Copy link
Copy Markdown
Member Author

@esphbot review

Copilot AI review requested due to automatic review settings August 19, 2026 01:15
@esphbot

esphbot commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

@bdraco: Both suggestions addressed in 270c207. Added a test pinning the auto resolved alphanumeric order on...

Verified all three on 270c207b with v9.1.2 installed. Platform test passes and fails under both degraded paths — host2/host10 breaks basic, and text too. Cycle gone; table-columns.ts re-export keeps call sites intact. tsc, eslint, prettier clean; test/components 381 files / 3141 tests pass.

One gap remains, non-blocking. Test pins alphanumeric only. Dropping text leaves it green. Mounted address with Zeta/apple/Banana — renders apple, Banana, Zeta, so text resolves for digit-free columns; basic would give Banana, Zeta, apple. text also backstops an alphanumeric miss in column_getAutoSortFn. One extra case in that describe covers it.

@esphbot

esphbot commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

PR Review — Migrate device table to TanStack Table v9

Both prior suggestions are genuinely addressed. Verified against the real v9 packages — merge-ready with one small coverage nit.

Specifically good in this round:

  • The new sort test actually discriminates. The fixture is chosen with care: host2/host10 breaks a basic fallback and a text fallback, BK72XX covers the case dimension. I ran it on a fresh checkout with @tanstack/lit-table@9.1.2 installed — it passes, and I confirmed by reading column_getAutoSortFn that both degraded paths would produce a different order rather than coincidentally the same one. It pins behavior, not implementation.
  • The DeviceRow move is a clean cycle break. device-row.ts is type-only, table-columns.ts re-exports it (export type { DeviceRow }), so every existing call site — including test/components/dashboard/table-columns.test.ts — is untouched, and table-features.ts no longer points back at table-columns.ts. The runtime-value TDZ hazard I flagged is gone.
  • The docstring now names the failure mode, including the dev-only console.warn and the sortFn_datetime requirement for a future Date column. That matches what the package actually does.

Verification on 270c207b with v9 installed: tsc --noEmit exit 0, eslint src test --max-warnings=0 exit 0, prettier --check clean, test/components 381 files / 3141 tests all passing, and the three directly-touched test files pass. I also mounted the table by hand and confirmed the search box still filters rows through v9's global filtering (search = "beta" → one row) and that a digit-free column sorts case-insensitively via text.

  • Suggestion: the new test locks alphanumeric but not text; removing text from the registry silently makes address / comment / area / status case-sensitive with a green suite. A digit-free mixed-case case in the same describe closes it.
  • Suggestion: device-row.ts splits two type imports of api/types/devices.js across two statements — collapse to one.

🟢 Suggestions

1. New sort test pins `alphanumeric` only — dropping `text` from the registry stays green
test/components/dashboard/device-table.test.ts:142-169

The new test closes the gap I raised last round for alphanumeric, and it discriminates correctly: I ran it against v9.1.2 and confirmed host2 before host10 fails under a basic fallback, and under a text fallback too (text lowercases but still puts host10 first). So removing alphanumeric is caught.

What is still unpinned is the other half of the registry. text is load-bearing here for two separate reasons, and neither is covered:

  • It is what digit-free string columns resolve to. I mounted the table on this branch with address values Zeta.local / apple.local / Banana.local and initialSorting: [{id: "address"}]; the rendered order was apple, Banana, Zeta — case-insensitive, i.e. sortFn_text. Drop text from the registry and column_getAutoSortFn returns sortFn_basic, giving Banana, Zeta, apple. Same exposure for comment, area, config and status whenever their sampled values contain no digits. The platform fixture all contains digits or resolves before text is consulted, so it stays green through that change.
  • It is also the secondary fallback for alphanumeric. In rowSortingFeature.utils.js, an alphanumeric miss retries sortFns?.text before falling through to basic — so text backstops the entry the new test does cover.

Concrete fix: add a second case to the same describe sorting a digit-free column (address is convenient — visible by default, plain valueCell) over mixed-case values, asserting apple.local, Banana.local, Zeta.local. That order distinguishes text from basic and from textCaseSensitive. This is the same point Copilot raised and self-suppressed; I verified it holds against the real package.

Non-blocking — the registry is correct as shipped.

expect(order).toEqual(["BK72XX", "esp32", "esp32-c3", "host2", "host10", "rp2040"]);

Checklist

  • Typecheck passes on the branch with v9 installed
  • Affected tests pass (test/components: 381 files / 3141 tests)
  • Lint and format checks pass
  • New sort test genuinely fails under the basic/text fallbacks
  • Import cycle between table-features and table-columns broken
  • Existing DeviceRow import sites unchanged by the module move
  • Sorting / filtering / visibility / pagination behavior matches v8
  • No backward-incompatible change to persisted preference shapes
  • Every registered sortFn covered by a test — suggestion #1
  • Diff matches the PR description; no scope creep

Important

The branch moved during review. This review was performed against HEAD=270c207, but the PR branch now points at c0f1e39. Commits pushed after the review started are not reflected below — re-run /review to cover them.


Automated review by Kōan (Claude) HEAD=270c207 10 min 24s

@esphbot esphbot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tip

No blocking issues found — ready to merge.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 12 out of 13 changed files in this pull request and generated no new comments.

Files not reviewed (1)
  • pnpm-lock.yaml: Generated file

@bdraco

bdraco commented Aug 19, 2026

Copy link
Copy Markdown
Member Author

Suggestion 1 was already addressed in c0f1e39, which the review notes it could not see; it pins the text entry by sorting the digit-free comment column over kitchen, Bedroom, attic and asserting attic, Bedroom, kitchen, an order that fails under both basic and textCaseSensitive. Suggestion 2 is fixed in the commit above, the two device-row type imports are now one statement.

@esphbot review

Copilot AI review requested due to automatic review settings August 19, 2026 01:22

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 12 out of 13 changed files in this pull request and generated no new comments.

Files not reviewed (1)
  • pnpm-lock.yaml: Generated file

@bdraco
bdraco merged commit 3738dc3 into main Aug 19, 2026
14 checks passed
@bdraco
bdraco deleted the tanstack-table-v9 branch August 19, 2026 01:26
@bdraco

bdraco commented Aug 19, 2026

Copy link
Copy Markdown
Member Author

@esphbot review

@github-actions github-actions Bot locked and limited conversation to collaborators Aug 21, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

dependencies Dependency updates

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants